package com.chenxin.wms.controller;

import com.chenxin.common.annotation.Log;
import com.chenxin.common.core.controller.BaseController;
import com.chenxin.common.core.domain.AjaxResult;
import com.chenxin.common.core.page.TableDataInfo;
import com.chenxin.common.enums.BusinessType;
import com.chenxin.common.utils.poi.ExcelUtil;
import com.chenxin.wms.domain.ModuleSerial;
import com.chenxin.wms.service.IModuleSerialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 自生成序号Controller
 *
 * @author gry
 * @date 2025-04-12
 */
@RestController
@RequestMapping("/wms/serial")
public class ModuleSerialController extends BaseController {
    @Autowired
    private IModuleSerialService moduleSerialService;

/**
 * 查询自生成序号列表
 */
@PreAuthorize("@ss.hasPermi('wms:serial:list')")
@GetMapping("/list")
    public TableDataInfo list(ModuleSerial moduleSerial) {
        startPage();
        List<ModuleSerial> list = moduleSerialService.selectModuleSerialList(moduleSerial);
        return getDataTable(list);
    }

    /**
     * 导出自生成序号列表
     */
    @PreAuthorize("@ss.hasPermi('wms:serial:export')")
    @Log(title = "自生成序号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModuleSerial moduleSerial) {
        List<ModuleSerial> list = moduleSerialService.selectModuleSerialList(moduleSerial);
        ExcelUtil<ModuleSerial> util = new ExcelUtil<ModuleSerial>(ModuleSerial. class);
        util.exportExcel(response, list, "自生成序号数据");
    }

    /**
     * 获取自生成序号详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:serial:query')")
    @GetMapping(value = {"/", "/{serialId}"})
    public AjaxResult getInfo(@PathVariable(value = "serialId", required = false) Long serialId) {
        return success(moduleSerialService.selectModuleSerialBySerialId(serialId));
    }
}
